import React,{useState,useEffect} from 'react';
import {Image,Dimensions} from 'react-native';
type Pros = {
    uri: string;
};
const {width:SCREEN_WIDTH} = Dimensions.get("window");
const SHOW_WIDTH = SCREEN_WIDTH - 18 >>1
export default ({uri}:Pros) => {
    const [height, setHeight] = useState(200);
    useEffect(()=> {
        Image.getSize(uri, (width:number, height:number)=> {
            const showHeigth = SHOW_WIDTH *height/width;
            setHeight(showHeigth);
        })
    }, [uri]);
    return (<Image style={{width: SHOW_WIDTH,height: height,resizeMode:'cover'}} source={{uri:uri}} />);
}